<?php
class AMS_Core_Model_Collection extends AMS_Core_Model_Abstract implements Iterator {
    protected $items = array();
    
    public function current() {
        return current($this->items);
    }
    public function next() {
        return next($this->items);
    }
    public function key() {
        return key($this->items);
    }
    public function valid() {
        $key = key($this->items);
        return ($key !== NULL && $key !== FALSE);
    }
    public function rewind(){
        reset($this->items);
    }
    
    public function add($value) {
        if ($value instanceof AMS_Core_Model_Abstract && $value->getName())
            $this->items[$value->getName()] = $value;
        else
            $this->items[] = $value;
    }
}
?>
